package com.sensorfriendly.ui;

import java.util.List;

import com.sensorfriendly.R;
import com.sensorfriendly.R.id;
import com.sensorfriendly.R.layout;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
 
/**
 * not being used right now
 *
 */
public class ImageAdapter extends BaseAdapter {
	private Context context;
	private final List<String> categoryList;
 
	public ImageAdapter(Context context, List<String> categoryList) {
		this.context = context;
		this.categoryList = categoryList;
	}
 
	public View getView(int position, View convertView, ViewGroup parent) {
 
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View gridView;
 
		if (convertView == null) {
 
			gridView = new View(context);
 
			// get layout from buttons.xml
			gridView = inflater.inflate(R.layout.buttons, null);
 
			// set value into textview
			TextView textView = (TextView) gridView
					.findViewById(R.id.grid_item_label);
			textView.setText(categoryList.get(position));
 
			// set image based on selected text
			ImageView imageView = (ImageView) gridView
					.findViewById(R.id.grid_item_image);
 
			String mobile = categoryList.get(position);
 
			imageView.setImageResource(context.getResources().getIdentifier(mobile.toLowerCase(),null,null));
 
		} else {
			gridView = (View) convertView;
		}
 
		return gridView;
	}
 
	public int getCount() {
		return categoryList.size();
	}
 
	public Object getItem(int position) {
		return null;
	}
 
	public long getItemId(int position) {
		return 0;
	}
 
}